<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:sec="http://www.springframework.org/security/facelets/tags">
	
<h:body>
	<ui:composition template="/templates/templateCRUD.xhtml">
		<ui:param name="tituloCadastro" value="Cadastro de Convênios por Empresa" />
		<ui:param name="tituloPesquisa" value="Pesquisa de Convênios por Empresa" />
		<ui:param name="tituloGrid" value="Lista de Convênios por Empresa" />
		<ui:param name="mbean" value="${convenioEmpresaMB}" />
		<ui:define name="cadastro">
			<p:tabView>
				<p:tab title="Dados Aviso">
					<p:focus for="empresaCadastro"/>
					<h:panelGrid columns="3">
						<h:outputText value="Empresa (*): "/>
						<p:selectOneMenu value="#{mbean.bean.empresa}" disabled="#{not mbean.inclusao}" label="Empresa" required="true"  id="empresaCadastro">
							<f:selectItem itemLabel="#{msg.opcaoSelecionarCombo}" itemValue="#{null}"/>
							<f:selectItems value="#{mbean.empresas}" var="empresa" itemLabel="#{empresa.nomeFantasia}"/>
							<f:converter converterId="empresaConverter"/>
							<p:ajax listener="#{mbean.selecionarOpcaoCombo}" event="change" update="@form"/>
						</p:selectOneMenu>
						<p:message for="empresaCadastro" showDetail="true" showSummary="true"/>
						
						<h:outputText value="Convênio (*): "/>
						<p:selectOneMenu value="#{mbean.bean.convenio}" disabled="#{not mbean.inclusao}" label="Convênio" required="true"  id="convenioCadastro">
							<f:selectItem itemLabel="#{msg.opcaoSelecionarCombo}" itemValue="#{null}"/>
							<f:selectItems value="#{mbean.convenios}" var="convenio" itemLabel="#{convenio.nome}"/>
							<f:converter converterId="convenioConverter"/>
							<p:ajax listener="#{mbean.selecionarOpcaoCombo}" event="change" update="@form" immediate="true"/>
						</p:selectOneMenu>
						<p:message for="convenioCadastro" showDetail="true" showSummary="true"/>
						
						<h:outputText value="Observação: " />
						<p:inputTextarea value="#{mbean.bean.observacao}" disabled="#{mbean.readOnly}" cols="54" rows="5"
							required="false" label="Observação" id="descricaoCadastro"/>
					</h:panelGrid>
			     </p:tab>
			</p:tabView>
		</ui:define>

		<ui:define name="pesquisa">
			<h:panelGrid columns="2" cellpadding="4">
			    <h:outputText value="Empresa: "/>
				<p:selectOneMenu value="#{mbean.beanSearch.empresa}" label="Empresa">
					<f:selectItem itemLabel="#{msg.opcaoSelecionarCombo}" itemValue="#{null}"/>
					<f:selectItems value="#{mbean.empresas}" var="empresa" itemLabel="#{empresa.nomeFantasia}"/>
					<f:converter converterId="empresaConverter"/>
				</p:selectOneMenu>
			</h:panelGrid>
		</ui:define>
		
		<ui:define name="gridPesquisa">
			<p:column>
				<f:facet name="header">
					<h:outputText value="Empresa"/>
				</f:facet>
				<h:outputText value="#{registro.empresa.nomeFantasia}"/>
			</p:column>		
			<p:column>
				<f:facet name="header">
					<h:outputText value="Convênio"/>
				</f:facet>
				<h:outputText value="#{registro.convenio.nome}"/>
			</p:column>	
			<p:column>
				<f:facet name="header">
					<h:outputText value="Observação"/>
				</f:facet>
				<h:outputText value="#{registro.observacao}"/>
			</p:column>		
		</ui:define>
	</ui:composition>
</h:body>
</html>
